<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>购物车</title>
	
	<!-- jQuery  -->
	<script type="text/javascript" src="/static/plugins/jquery/jquery-3.6.0.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/static/plugins/layui/2.7.6/css/layui.css" media="all" />
	<script src="/static/plugins/layui/2.7.6/layui.js" charset="utf-8"></script>

    <!-- 基于laiui的表格 -->
    <script type="text/javascript" src="/static/js/business/tpProductCarefullyChosen/simple_table_choiceshop_cart.js"></script>

	<style>
		body {
			font-family: 微软雅黑;
		}
		.item {display: flex; align-items: center; font-size: 16px;}
		.item div {width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
		.btn-db {
			border: none;
			background-color: #1E9FFF;
			color: #fff;
			font-size: 14px;
			padding: 5px 15px;
			border-radius: 10px;
		}
	</style>
</head>
<body>
<div style="margin: 0 auto; background-color: #fff; padding: 30px 0;">

	<div style="padding: 10px;">
		<div class="tit" style="font-weight: 700;">
			<span>折扣信息：</span>
		</div>
		<div style="width: 100%; border-top:0.5px dashed rgb(0 135 250 / 40%) !important; border-bottom: 0; margin: 5px 0;">
		</div>
		<div style="height: 10px;"></div>
		<div class="item">
			<div style="text-align: center;" th:each="priceInfo: ${dto.priceInfoArr}">
				<div style="text-align: center; width: 100%; font-size: 36px; font-weight: 700; color: #FF5722;">
					[[${priceInfo.title}]]
				</div>
				<div style="text-align: center; width: 100%; font-size: 12px; font-weight: 400;">
					[[${priceInfo.subTitle}]]
				</div>
			</div>
		</div>
		
		<div style="width:100%;">
		</div>
	</div>

	<div style="padding: 10px;">
		<div class="tit" style="font-weight: 700;">
			<span>购物车信息：</span>
		</div>
		<div style="width: 100%; border-top:0.5px dashed rgb(0 135 250 / 40%) !important; border-bottom: 0; margin: 5px 0;">
		</div>
		
		<div style="width:100%;">
			<div id="simple_table_choiceshop_cart">
			</div>
		</div>
		<script th:inline="javascript">
		var tableOfChoiceshopCart = null;
		//使用layui的sku模块
		layui.use(['form', 'simple_table_choiceshop_cart', 'jquery'], function () {
			var $ = layui.jquery, simple_table_choiceshop_cart = layui.simple_table_choiceshop_cart,
				form = layui.form;
			
			tableOfChoiceshopCart = simple_table_choiceshop_cart.init({
				id: 'simple_table_choiceshop_cart',
				data: $.parseJSON(JSON.stringify([[${dto.detailArr}]])),
				discountArr: $.parseJSON(JSON.stringify([[${dto.discountArr}]]))
			});
		});
		</script>
	</div>
<div class="layui-form-item" style="margin-top: 15px;">
<div class="layui-inline" style="display: flex;">
  <label class="layui-form-label"><span style="color: red">*</span>调拨公司：</label>
  <div class="layui-input-block" style="margin-left: 0; position: relative;">
      <input type="text" class="layui-input buttontext" style="width: 250px;" name="vGsMc" id="vGsMc" autocomplete="off" readonly lay-verify="required"/>
      <i class="layui-icon layui-icon-more getMore" style="position: absolute;top: 11px;right: 9px;" id="id_select_company"></i>
    </div>
</div>
<div style="color: red;text-align:center;margin-top: 25px; font-size: 16px; padding: 10px;">
<div style="color: red;text-align:left; margin-left: 80px;">
	<span>特别提醒：<br>1、逸思精品调拨后，不可退回！<br>2、请确认好调拨信息再执行操作！<br>3、该操作一经确定即完成调拨！</span>
</div>
</div>
</div>
	
	<div style="width: 100%; background-color: #FDF5E6;">
		<div>
			<div style="color: #FF5722; width: 60%; float: left; text-align: left; height: 40px; line-height: 40px;">
				<div style="margin-left: 10%;">
					<span></span>
				</div>
				<div style="margin-left: 10%;">
				</div>
			</div>
			<div style="color: #FF5722; float: left; font-weight: 900; width: 35%; text-align: right; padding: 0 20px; font-size: 18px;">
				<div style="float: right;">
					<table style="margin-right: 0;">
						<tr>
							<td><span style="font-size: 18px;">总数量：</span></td>
							<td style="text-align: left;"><span id="id_total_num">--</span></td>
						</tr>
						<tr>
							<td><span style="font-size: 18px;">总金额(¥)：</span></td>
							<td style="text-align: left;"><span id="id_total_price">--</span></td>
						</tr>
						<tr>
							<td><span style="font-size: 18px;">折扣：</span></td>
							<td style="text-align: left;"><span id="id_discount">--</span></td>
						</tr>
						<tr>
							<td><span>折后总价(¥)：</span></td>
							<td style="text-align: left;"><span style="font-size: 36px;" id="id_total_price_discount">--</span></td>
						</tr>
					</table>
				</div>
			</div>
		</div>
		<div style="width: 95%; text-align: right; padding: 5px 20px;">
			<form class="layui-form" id="formId" method="post" action="/hr/choiceshop/editSetting">
				<button type="button" class="btn-db" lay-submit lay-filter="formSubmit">调拨</button>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript">
	var gridColumns = null;
	var moduleTable = null;
	var vGsMc = "",
	vGsBm = "",
	vGsJc = "";

    var $, layer, laydate, form;
    layui.config({
    	//自定义layui组件的目录,设定扩展的layui模块的所在目录，一般用于外部模块扩展
    	base: '/static/js/layui_extends/'
    }).use(['table', 'laydate', 'form', 'layer', 'jquery', 'element', 'laypage', 'YsModal'], function () {
        $ = layui.$,
        layer = layui.layer,
        laydate = layui.laydate,
        form = layui.form;

        $('.btn-db').on('click', function () {
            var choiceShop = tableOfChoiceshopCart.getData()
            var nums = $('#id_total_num').html() * 1
            if (!nums > 0) {
                $.modal.msgWarning('请选择至少一种商品！');
                return
            }
        	
        	// 判断数量是否足够调拨
        	if(tableOfChoiceshopCart.isAbleAllot() == false) {
                layer.msg('不能低于最少数量')
        		return;
        	}
        	
    		var indexOfLoading = layer.load(1, {
    			shade: [0.5,'#000000'] //0.1透明度的白色背景
    		});

            $.post("/hr/choiceshop/commodityAllocation", {
                'choiceShop': JSON.stringify(choiceShop),
                'corporate': JSON.stringify({
                    'vGsBm': vGsBm,
                    'vGsJc': vGsJc,
                    'vGsMc': vGsMc,
                })
            }, function (res) {
                layer.closeAll()
                layer.msg(res.msg)
            });
        })
        
        // 绑定选择调拨公司
        $('#id_select_company').on('click', function () {
        	layui.YsModal.init({modalKey: 'THR_OperateCompanyApply', colCode: '', parentObj: window, extraData:{}})
        })
    });

	function matchValuesAfterModalSelectRadio(colCode, rowSelected, extraData) { // 选中数据后，匹配表单数值，用于YsModal回调
		
        $("#vGsMc").val(rowSelected.vGsMc);
        vGsMc = rowSelected.vGsMc
        vGsBm = rowSelected.vGsBm
        vGsJc = rowSelected.vGsJc
	}
</script>

</body>
</html>